/// [Non-abundant sums](https://projecteuler.net/problem=23)
fn main() {
    for num in &[28123] {
        let mut num_arr = [true; 28123];
        let num_vec = abundant_number(*num);
        let length = num_vec.len();
        for i in 0..length {
            for j in i..length {
                let k = num_vec[i] + num_vec[j];
                if k > 28123 {
                    break;
                }
                num_arr[k - 1] = false;
            }
        }
        let mut sum = 0;
        for (i, stat) in num_arr.iter().enumerate() {
            if *stat {
                sum += i + 1;
            }
        }
        println!("{}", sum);
    }
}
///
fn abundant_number(num_len: usize) -> Vec<usize> {
    let mut num_vec = vec![];
    for i in 2..num_len {
        if i < proper_divisor(i).iter().fold(0, |sum, x| sum + x) {
            num_vec.push(i);
        }
    }
    num_vec
}
/// 正约数
fn proper_divisor(num_len: usize) -> Vec<usize> {
    let mut num_vec = vec![];
    for i in 1..=(num_len / 2) {
        if num_len % i == 0 {
            num_vec.push(i);
        }
    }
    num_vec
}
